package com.example.a14110100420.yuejian.Model;

import com.example.a14110100420.yuejian.JaveBean.User;
import com.example.a14110100420.yuejian.Service.UserService;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Lee1 on 2017/9/26.
 */

public class UserModel {
    private Retrofit retrofit;
    public UserModel(){
        retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("http://172.24.10.175/workout/api.php/")
                .build();
    }
    public retrofit2.Call<User> login(String tel, String pwd){
        UserService userService = retrofit.create(UserService.class);
        return userService.getLogin(tel,pwd);
    }

    public retrofit2.Call<User> register(String user,String password,String password2,String tele,String aemail){
        UserService userService = retrofit.create(UserService.class);
        return userService.register(user,password,password2,tele,aemail);
    }

    public retrofit2.Call<User> getUserById(int uid){
        UserService userService=retrofit.create(UserService.class);
        return userService.getUserById(uid);
    }

    public retrofit2.Call<User> updateUserById (int uid, String username, String password, String telephonenumber, String address){
        UserService userService=retrofit.create(UserService.class);
        return userService.updateUserById(uid,username,password,telephonenumber,address);
    }
}
